package com.monkeyboy.second.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description
 * @Author Gavin
 * @date 2020.04.27 17:17
 */
public class CachedThreadPool {
    public static void main(String[] args) {
        //这种线程池的线程数量是没有上限的，使用时候注意oom的情况
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 1000; i++) {
            executorService.execute(new Task());
        }
        System.err.println("线程池的任务加完了。");
    }
}
